package com.jlect.swebing.ui.client.button;

/**
 * Base button class implementation
 *
 * @author Sergey Kozmin
 * @since 22.11.2007 10:44:29
 */
public class ButtonBase {
    private ButtonModel model;
    private ButtonView view;
    private ButtonController controller;

    public ButtonBase(ButtonModel model, ButtonView view, ButtonController controller) {
        setButtonModel(model);
        setButtonView(view);
        setButtonController(controller);
    }

    public ButtonBase() {
    }

    public ButtonModel getModel() {
        return model;
    }

    public void setButtonModel(ButtonModel model) {
        if(model == null) {
            throw new IllegalArgumentException("Model could not be a null object. ");
        }
        this.model = model;
    }

    public ButtonView getView() {
        return view;
    }

    public void setButtonView(ButtonView view) {
        if(view == null) {
            throw new IllegalArgumentException("View could not be a null object. ");
        }
        this.view = view;
        view.setModel(model);
    }

    public ButtonController getController() {
        return controller;
    }

    public void setButtonController(ButtonController controller) {
        if(controller == null) {
            throw new IllegalArgumentException("Controller could not be a null object. ");
        }
        this.controller = controller;
        controller.setModel(model);
        controller.setView(view);
    }

    public void setText(String text) {
        model.setButtonText(text);
    }
}
